Tokio Compat 0.2
= "0.1"
This crate includes utilities around integrating Tokio with other runtimes by allowing the context to be attached to futures. This allows spawning futures on other executors while still using Tokio to drive them. This can be useful if you need to use a Tokio based library in an executor/runtime that does not provide a Tokio context.
Be aware that the .compat()
region allows you to use both Tokio 0.2 and 0.3
features. It is not the case that you opt-out of Tokio 0.3 when you are inside
a Tokio 0.2 compatibility region.
Basic usage:
use ;
use FutureExt;
async
Usage on async function:
use ;
use FutureExt;
async
async
Be aware that the constructors of some type require being inside the context. For
example, this includes TcpStream
and delay_for
.
use delay_for;
use FutureExt;
async
Of course the above would also work if the surrounding async function was called
with .compat()
.